<?php
class Rockitbos_Model_App extends Zend_Controller_Front
{
    static function getApps()
    {
        $apps = array();
        $modules = array();

        $front = parent::getInstance();
        $modules = $front->getControllerDirectory();

        foreach ($modules as $module => $path) {
            //Checks if the config file exists
            $appIni = realpath($path . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "configs" . DIRECTORY_SEPARATOR . "app.ini");
            if ($appIni != FALSE) {
                // App data are stored into a new array
                $apps[$module]['path'] = $path;
                // Load header data
                $appData = new Zend_Config_Ini($appIni, 'app');
                // Merging all datas in new array
                $apps[$module] = array_merge($apps[$module], $appData->toArray());
            }
        }
        return $apps;
    }
    static function getFavorites()
    {
        $apps = array();

        $front = parent::getInstance();
        $file = realpath($front->getModuleDirectory().'/configs/favorites.ini');

        if ($file != FALSE) {
            // Load header data
            $configFavorites = new Zend_Config_Ini($file, 'favorites');
            $favorites = $configFavorites->app->toArray();

            foreach ($favorites as $favorite) {
                $appIni = realpath(APPLICATION_PATH .'/modules/' . $favorite . '/configs/app.ini');
                if ($appIni != false) {
                    $appData = new Zend_Config_Ini($appIni, 'app');
                    $apps[$favorite] = $appData->toArray();
                }
            }
            return $apps;
        }
        return FALSE;




    }
}